package com.nmsl.statistic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import com.nmsl.statistic.domain.OperInfo;
import com.nmsl.statistic.mapper.OperInfoMapper;
import com.nmsl.statistic.vo.McslfAttDetails;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.nmsl.common.annotation.Log;
import com.nmsl.common.core.controller.BaseController;
import com.nmsl.common.core.domain.AjaxResult;
import com.nmsl.common.enums.BusinessType;
import com.nmsl.statistic.domain.RetailAtt;
import com.nmsl.statistic.service.IRetailAttService;
import com.nmsl.common.utils.poi.ExcelUtil;
import com.nmsl.common.core.page.TableDataInfo;

/**
 * 零售附加项目Controller
 * 
 * @author ruoyi
 * @date 2025-02-16
 */
@RestController
@RequestMapping("/tatistic")
public class RetailAttController extends BaseController
{
    @Autowired
    private IRetailAttService retailAttService;

    /**
     * 查询零售附加项目列表
     */
    @PreAuthorize("@ss.hasPermi('tatistic:tatistic:list')")
    @GetMapping("/list")
    public TableDataInfo list(@RequestBody RetailAtt retailAtt)
    {
        startPage();
        List<RetailAtt> list = retailAttService.selectRetailAttList(retailAtt);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('tatistic:tatistic:list')")
    @GetMapping("/McslfAttrlist")
    public TableDataInfo checkMcslfAttrlist( McslfAttDetails retailAtt)
    {
        Page page = mystartPage();
        List<McslfAttDetails> as = retailAttService.checkMcslfAttrlist(retailAtt);
        return mygetDataTable(as,page.toPageInfo());
    }

    /**
     * 导出零售附加项目列表
     */
    @PreAuthorize("@ss.hasPermi('tatistic:tatistic:export')")
    @Log(title = "零售附加项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RetailAtt retailAtt)
    {
        List<RetailAtt> list = retailAttService.selectRetailAttList(retailAtt);
        ExcelUtil<RetailAtt> util = new ExcelUtil<RetailAtt>(RetailAtt.class);
        util.exportExcel(response, list, "零售附加项目数据");
    }

    /**
     * 获取零售附加项目详细信息
     */
    @PreAuthorize("@ss.hasPermi('tatistic:tatistic:query')")
    @GetMapping(value = "/{retailAttId}")
    public AjaxResult getInfo(@PathVariable("retailAttId") String retailAttId)
    {
        return success(retailAttService.selectRetailAttByRetailAttId(retailAttId));
    }

    /**
     * 新增零售附加项目
     */
    @PreAuthorize("@ss.hasPermi('tatistic:tatistic:add')")
    @Log(title = "零售附加项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RetailAtt retailAtt)
    {
        return toAjax(retailAttService.insertRetailAtt(retailAtt));
    }

    /**
     * 修改零售附加项目
     */
    @PreAuthorize("@ss.hasPermi('tatistic:tatistic:edit')")
    @Log(title = "零售附加项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RetailAtt retailAtt)
    {
        return toAjax(retailAttService.updateRetailAtt(retailAtt));
    }

    /**
     * 删除零售附加项目
     */
    @PreAuthorize("@ss.hasPermi('tatistic:tatistic:remove')")
    @Log(title = "零售附加项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{retailAttIds}")
    public AjaxResult remove(@PathVariable String[] retailAttIds)
    {
        return toAjax(retailAttService.deleteRetailAttByRetailAttIds(retailAttIds));
    }
    @Autowired
    OperInfoMapper operInfoMapper;
    @RequestMapping("/oper")
    public AjaxResult getOper(){
        List<OperInfo> list = operInfoMapper.selectAll();
        System.out.println(list);
        return AjaxResult.success(list);
    }
}
